<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Quản lý danh mục</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <div class="table_form">
        <form class="search_form" name="search_form" action="" method="get">
        Tìm kiếm: 
        <input class="input" type="text" name="keyword" value="<?php echo $this->searchValue; ?>" />
        <input class="button" type="submit" name="search" value="Tìm kiếm" />
        <span class="msg"><?php echo $this->errorSearch; ?></span>
        </form>
        
        <form class="list_cat_form" name="list_cat_form" action="" method="post">
        <div style="float: right;">
        	<p id="add_form">Số lượng: <span class="msg"><?php echo $this->total; ?></span> danh mục</p>
	        <?php echo $this->formSubmit('add', 'Thêm mới', array('class' => 'button', 'id' => 'add_form')); ?>
	        <?php echo $this->formSubmit('refresh', 'Làm mới', array('class' => 'button', 'id' => 'add_form')); ?>
	        <?php echo $this->formSubmit('orders', 'Sắp xếp', array('class' => 'button', 'id' => 'del_form')); ?>
        </div>
        <table class="table_style">
            <tr class="head_table">
                <td width="30px">ID</td>
                <td width="30px">ID Cha</td>
                <td width="250px">Tên danh mục</td>
                <td width="30px">Cấp</td>
                <td width="30px">Trái</td>
                <td width="30px">Phải</td>
                <td width="50px">Sắp xếp</td>
                <td width="50px">Trạng thái</td>
                <td class="tools">&nbsp;</td>
                <td class="tools">&nbsp;</td>
            </tr>
            <?php 
            	$category = new AdminDthink_Model_Category();
            	foreach($this->data as $value) : 
		            $levelCss = '';
		            if($value['level'] == 0){
		            	$name = '<b style="color:red">' . $value['cat_name'] . '</b>';
		            }else if($value['level'] == 1){
		            	$name = '<b> + ' . $value['cat_name'] . '</b>';
		            }else{
		            	$name = '<b> - - ' . $value['cat_name'] . '</b>';
		            	$levelCss =  'padding-left: ' . (20 * $value['level']) . 'px;';
		            }
	            
		            $orderName	= 'ordering[' . $value['lft'] . ']';
		            $orderValue	= $category->getNodeOrdering($value['parents'],$value['lft']);
            ?>
            <tr class="records">
            	<td><?php echo $value['cat_id']; ?></td>
            	<td><?php echo $value['parents']; ?></td>
                <td style="<?php echo $levelCss;?>"><?php echo $name; ?></td>
                <td><?php echo $value['level']; ?></td>
                <td><?php echo $value['lft']; ?></td>
                <td><?php echo $value['rgt']; ?></td>
                <td><?php echo $this->formText($orderName, $orderValue, array(
                		'size' => 4, 
                		'id' => $orderName, 
                		'style' => 'text-align: center'
                	)); ?></td>
                <td><?php 
               		if($value['status'] == 1)
               		{
               			echo 'Hiển thị';
               		} 
               		else
               		{
               			echo 'Ẩn đi';
               		} ?></td>
                <td><a class="edit" title="Sửa" href="<?php echo $this->baseUrl('/admin-dthink/category/edit?id=' . $value['cat_id']); ?>"></a></td>
                <td><a class="remove" title="Xóa" onclick="return remove_alert()" href="<?php echo $this->baseUrl('/admin-dthink/category/delete?id=' . $value['cat_id']); ?>"></a></td>
            </tr>
            <?php 
                endforeach;
            ?>
        </table>
        </form>
    </div>
</div><!-- End .main_content -->